<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const isDateValid = (...val) => !Number.isNaN(new Date(...val).valueOf());
        console.log(isDateValid('2022 08:22:00'));

        console.log(new Date('2022 08:22:00'));
        

        const dayDif = (date1,date2) => Math.ceil(Math.abs(date1.getTime()-date2.getTime())/86400000);
console.log(dayDif(new Date('2022-8-3'),new Date('2023-8-3')));
    </script>
</body>
</html>